package com.qyhl.shop.shop.showcase.detail;

import com.qyhl.shop.common.ShopUrl;
import com.qyhl.webtv.basiclib.utils.network.EasyHttp;
import com.qyhl.webtv.basiclib.utils.network.callback.SimpleCallBack;
import com.qyhl.webtv.basiclib.utils.network.exception.ApiException;
import com.qyhl.webtv.commonlib.entity.shop.ShopShowcaseBean;

public class ShopShowcaseDetailModel implements ShopShowcaseDetailContract.ShopShowcaseDetailModel {
    private ShopShowcaseDetailPresenter mPresenter;

    public ShopShowcaseDetailModel(ShopShowcaseDetailPresenter mPresenter) {
        this.mPresenter = mPresenter;
    }

    @Override
    public void getDetail(int itemId) {
        EasyHttp.post(ShopUrl.SHOP_SHOWCASE_DETAIL)
                .params("itemId", itemId + "")
                .execute(new SimpleCallBack<ShopShowcaseBean>() {
                    @Override
                    public void onError(ApiException e) {
                        mPresenter.setError("获取详情失败！");
                    }

                    @Override
                    public void onSuccess(ShopShowcaseBean bean) {
                        mPresenter.setDetail(bean);
                    }
                });
    }
}
